***Curtis RESTAT
***This file runs regressions found in Table 5 of the paper
**Change to directory where data and code were downloaded
**cd 

    pause on
    set more off
    clear all
    set mem 1G
    *#delimit 

*log using ../QWIageresults2015.log, replace

local groups all A02 A03 A04 A05 A06 A07 A08 /*Each Age-grouping has its own dataset*/
local out_vars lemp hires_rate seps_rate nempsep learnhirns learns /*These are the outcome vars in table 5*/

	
	
	
foreach group in `groups' {
	set matsize 10000
	use "qwi_`group'_table5.dta",clear

	qui do qwi_dataprep_table5.do
	unique state /*Note that the QWI does not contain data on all US states*/
		gen lemps=ln(emps+1)
		gen lemp=ln(emp+1)
		gen lhiras=ln(hiras)
		gen lseps=ln(seps)
		gen hires_rate=hiras/emp_base
		gen sep_rate=sep/emp_base
		gen hire_rate=hira/emp_base
		gen seps_rate=seps/emp_base
		gen cr_rate=frmjbgn/emp_base
		gen de_rate=frmjbls/emp_base
		gen crs_rate=frmjbgns/emp_base
		gen des_rate=frmjblss/emp_base
		gen learns=ln(earns)
		gen learnhirns=ln(earnhirns)
		gen lpayroll=ln(payroll)

	foreach out in `out_vars'{
		eststo: qui areg `out' postxNBPxint postxNBP postxint intxNBP windtrend* eindtrend* trendstatedum* i.ind_qtrf [aweight=emp_weight],abs(state_ind) rob cluster(NBPind)
	}

	esttab using "Table5.tex",se append title(`group') keep(postxNBPxint) star(* 0.10 ** 0.05 *** 0.01) 	
	eststo clear
	  
}
clear all 
*log close
exit
